//
//  ViewController.m
//  01-UIViewHomeWork
//
//  Created by QC.L on 16/7/14.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "ViewController.h"


#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface ViewController ()

@property (nonatomic, strong) UIView *backgroundView;
@property (nonatomic, strong) UIImageView *backgroundImageView;
@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UITextField *userNameTextField;
@property (nonatomic, strong) UITextField *keyTextField;
@property (nonatomic, strong) UIView *textFieldBgView;
@property (nonatomic, strong) UIView *textFieldWhiteLineView;
@property (nonatomic, strong) UIImageView *userImageView;
@property (nonatomic, strong) UIImageView *keyPassImageView;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) UIButton *forgetKeyPassButton;
@property (nonatomic, strong) UIView *leftWhiteLine;
@property (nonatomic, strong) UIView *rightWhiteLine;
@property (nonatomic, strong) UILabel *orLabel;
@property (nonatomic, strong) UIButton *registerButton;
@property (nonatomic, strong) UIButton *rambleButton;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor redColor];
    // 背景图
    self.backgroundImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backgroundImageView.backgroundColor = [UIColor whiteColor];
    self.backgroundImageView.image = [UIImage imageNamed:@"welcome_2.jpg"];
    [self.view addSubview:self.backgroundImageView];
    
    // 显示发白的View
    self.backgroundView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backgroundView.backgroundColor = [UIColor lightGrayColor];
    self.backgroundView.alpha = 0.35;
    [self.view addSubview:self.backgroundView];
    
    // logo
    self.logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH / 3 - 10, HEIGHT * 2 / 7)];
    self.logoImageView.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 4);
    self.logoImageView.backgroundColor = [UIColor clearColor];
    self.logoImageView.image = [UIImage imageNamed:@"logo_lagou.jpg"];
    [self.view addSubview:self.logoImageView];

    // 用户名和密码输入框的背景View
    self.textFieldBgView = [[UIView alloc] initWithFrame:CGRectMake(10, 370, WIDTH - 20, 91)];
    self.textFieldBgView.backgroundColor = [UIColor blackColor];
    self.textFieldBgView.alpha = 0.7;
    [self.view addSubview:self.textFieldBgView];
    self.textFieldBgView.layer.cornerRadius = 6;
    
    // 用户名输入框
    self.userNameTextField = [[UITextField alloc] initWithFrame:CGRectMake(55, 0, WIDTH - 20 - 55, 45)];
    self.userNameTextField.backgroundColor = [UIColor grayColor];
    self.userNameTextField.alpha = 0.3f;
    [self.textFieldBgView addSubview:self.userNameTextField];
    
    // 密码输入框
    self.keyTextField = [[UITextField alloc] initWithFrame:CGRectMake(55, 45, WIDTH - 75, 45)];
    self.keyTextField.backgroundColor = [UIColor grayColor];
    self.keyTextField.alpha = 0.3;
    [self.textFieldBgView addSubview:self.keyTextField];
    
    // 间隙
    self.textFieldWhiteLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 46, WIDTH - 20, 1)];
    self.textFieldWhiteLineView.backgroundColor = [UIColor whiteColor];
    self.textFieldWhiteLineView.alpha = 0.5;
    [self.textFieldBgView addSubview:self.textFieldWhiteLineView];
    
    // 用户名图片
    self.userImageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, 5, 30, 35)];
    self.userImageView.backgroundColor = [UIColor clearColor];
    self.userImageView.image = [UIImage imageNamed:@"icon_username.jpg"];
    [self.textFieldBgView addSubview:self.userImageView];
    
    // 密码图片
    self.keyPassImageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, 52, 30, 35)];
    self.keyPassImageView.backgroundColor = [UIColor clearColor];
    self.keyPassImageView.image = [UIImage imageNamed:@"icon_password.jpg"];
    [self.textFieldBgView addSubview:self.keyPassImageView];

    // 登录按钮
    self.loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.loginButton.backgroundColor = [UIColor colorWithRed:0.00f green:0.68f blue:0.53f alpha:1.00f];
    self.loginButton.frame = CGRectMake(10, 480, WIDTH - 20, 50);
    self.loginButton.layer.cornerRadius = 4;
    [self.view addSubview:self.loginButton];
    [self.loginButton setTitle:@"登 录" forState:UIControlStateNormal];
    [self.loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    // 忘记密码按钮
    self.forgetKeyPassButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.forgetKeyPassButton.backgroundColor = [UIColor clearColor];
    self.forgetKeyPassButton.frame = CGRectMake(10, 540, 60, 40);
    [self.forgetKeyPassButton setTitle:@"忘记密码" forState:UIControlStateNormal];
    [self.forgetKeyPassButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:self.forgetKeyPassButton];
    
    // or左边白线
    self.leftWhiteLine = [[UIView alloc] initWithFrame:CGRectMake(10, 650, 170, 2)];
    self.leftWhiteLine.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.leftWhiteLine];
    self.rightWhiteLine = [[UIView alloc] initWithFrame:CGRectMake(414 - 180, 650, 170, 2)];
    self.rightWhiteLine.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.rightWhiteLine];

    // 注册按钮
    self.registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.registerButton.frame = CGRectMake(0, 0, 200, 50);
    self.registerButton.center = CGPointMake(WIDTH / 2, 600);
    self.registerButton.backgroundColor = [UIColor clearColor];
    [self.registerButton setTitle:@"现在注册拉钩" forState:UIControlStateNormal];
    [self.registerButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [self.view addSubview:self.registerButton];
    [self.registerButton addTarget:self action:@selector(registerUser) forControlEvents:UIControlEventTouchUpInside];
    
    // 随便逛逛
    self.rambleButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.rambleButton.backgroundColor = [UIColor clearColor];
    self.rambleButton.frame = CGRectMake(0, 0, 100, 50);
    self.rambleButton.center = CGPointMake(WIDTH / 2, 700);
    [self.rambleButton setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [self.rambleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:self.rambleButton];
    
    // or
    self.orLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    self.orLabel.backgroundColor = [UIColor clearColor];
    self.orLabel.center = CGPointMake(WIDTH / 2, 650);
    self.orLabel.text = @"or";
    self.orLabel.textAlignment = NSTextAlignmentCenter;
    self.orLabel.font = [UIFont systemFontOfSize:22];
    self.orLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:self.orLabel];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
